Skip to content

London | 26-ITP-Jan | Johnny Vargas | Sprint 3 | Practice TDD#1212

Open
JohnnyBoyV wants to merge 1 commit intoCodeYourFuture:mainfrom
JohnnyBoyV:2-practice-tdd
Open

London | 26-ITP-Jan | Johnny Vargas | Sprint 3 | Practice TDD#1212
JohnnyBoyV wants to merge 1 commit intoCodeYourFuture:mainfrom
JohnnyBoyV:2-practice-tdd

Conversation

@JohnnyBoyV
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Did as asked for the Practice TDD.

@JohnnyBoyV JohnnyBoyV added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 7, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mistakenly sent.

Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Function implementation is correct.

  • Some test descriptions could be made clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consider testing a few more samples in this script - higher chance to detect bugs in code.

The original specification did not clearly state whether the character match should be case-sensitive.
Most people would probably assume that it is, but to demonstrate our understanding or clarify the assumption we made,
we could add test cases to convey this. For examples,

  • A case to show that the match is case sensitive
  • A case to show that the function is expected to work also for non-alphabets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test categories in this script do not yet cover all possible numbers.

Comment on lines +23 to +34
test("should print the string once", () => {
const str = "hello";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hello");
});

// Case: Handle count of 0:
// Given a target string `str` and a `count` equal to 0,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string.
test("should print nothing", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "print" would suggest the function is expected to output (instead of returning) the resulting string.

  • In TDD, the test description (or test name) should clearly explain what behavior the function should exhibit.
    The goal is that someone reading the test can understand the requirement without reading another spec.

A common format is: should <expected_behavior> when <condition>.

Can you also include the "condition" part into these descriptions?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants